package com.woniu.adopt.mapper;

import com.woniu.adopt.entity.Pet;
import com.woniu.adopt.entity.RescueStation;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface RescueStationMapper {


    //根据id删除
    int deleteByPrimaryKey(Integer id);

    //添加救助站
    int insert(RescueStation record);

    //根据id进行查询
    RescueStation selectByPrimaryKey(Integer id);

    //查询所有的救助站
    List<RescueStation> selectAll();

    //更新站点信息
    int updateByPrimaryKey(RescueStation record);

    //模糊查询 （救助站名称，地址）+ 分页
    List<RescueStation> selectRSByName(@Param("name") String name, @Param("address") String address);

    //模糊查询 --历史（救助站名称，地址）+ 分页
    List<RescueStation> selectOldRSByName(@Param("name") String name, @Param("address") String address);

    @Select("select * from t_pet where res_id = #{RSId} and state = 0")
    List<Pet> selectPetByRSid(@Param("RSId") int id);

    @Update("update t_rescuestation set del = 1 where id = #{id}")
    int updateDelByKey(@Param("id") int id);

    @Select("select * from t_rescuestation where id = #{id}")
    RescueStation queryRSByKey(int id);
}